<template>
    <div>
        <!-- 基本信息 -->
        <div class="bg-white ">
            <BaseHead>基本信息</BaseHead>
            <div class="p-[10px]">
                <el-descriptions title="" :column="2" border label-width="140">
                    <el-descriptions-item label-class-name="gdlable" label="奖励批准号">{{
                    ruleForm.honorSn
                }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="获奖类型">{{
                        ruleForm.honorNumber == 1 ? '成果奖' : "人才奖"
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="奖励名称">{{
                        ruleForm.name
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="成果名称">{{
                        ruleForm.productName
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="发证机关">{{
                        ruleForm.honorUnit
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="获奖级别">
                        <Feedback :id="ruleForm.honorLevelId" :list="hjjbList">
                        </Feedback>
                    </el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="获奖等级">
                        <Feedback :id="ruleForm.honorGradeId" :list="hjdjList">
                        </Feedback>
                    </el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="奖励类别">
                        <Feedback :id="ruleForm.honorTypeId" :list="hjnbList">
                        </Feedback>
                    </el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="获奖日期">{{
                    ruleForm.honorDate ? ruleForm.honorDate.slice(0, 10) : ''
                }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="成果形式">{{
                        ruleForm.productMode
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="总参加单位数">{{
                        ruleForm.totalUnitNum
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="所属单位">
                        <Feedback :id="ruleForm.unitId" :list="zcgsdwList" :mapping="['codeColumn', 'valueColumn']">
                        </Feedback>
                    </el-descriptions-item>
                </el-descriptions>
            </div>
        </div>
        <!-- 详细信息 -->
        <div class="bg-white mt-[10px]">
            <BaseHead>详细信息</BaseHead>
            <div class="p-[10px]">
                <el-descriptions title="" :column="2" border label-width="140">
                    <el-descriptions-item label-class-name="gdlable" label="合作类型">{{
                    ruleForm.cooperationType == 1 ? '独立申请' : "联合申请"
                }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="获奖金额">{{
                        ruleForm.honorFee
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="本校奖金比例"
                        v-if="ruleForm.cooperationType == 2">{{
                    ruleForm.scale
                }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="完成单位">{{
                        ruleForm.completeUnit
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="单位排名">{{
                        ruleForm.unitOrderId
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="学科门类">{{
                        ruleForm.subjectClassId == 2 ? '科技类' : "社科类"
                    }}</el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="学科分类">
                        <Feedback :id="ruleForm.subjectId"
                            :list="ruleForm.subjectClassId == 2 ? kjxkflList : skxkflList" :mapping="['id', 'label']">
                        </Feedback>
                    </el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="项目来源">
                        <Feedback :id="ruleForm.projectSourceId" :list="xmlyList" :mapping="['id', 'label']">
                        </Feedback>
                    </el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="奖励证书">
                        <div v-for="item in ruleForm.fileList" :key="item.id">{{ item.fileName
                            }}<el-link type="primary" style="margin-left: 8px;"
                                @click="downloadMet(item.id)">下载</el-link>
                        </div>
                    </el-descriptions-item>
                    <el-descriptions-item label-class-name="gdlable" label="备注">{{
                    ruleForm.note
                }}</el-descriptions-item>
                </el-descriptions>
            </div>
        </div>
        <!-- 完成人信息 -->
        <div class="bg-white mt-[10px]">
            <BaseHead>完成人信息 </BaseHead>
            <div class="p-[10px]">
                <el-table :data="tableData" border style="width: 100%">
                    <el-table-column align="center" type="index" label="署名顺序" width="80" />
                    <el-table-column align="center" prop="authorType" label="完成人类型">
                        <template #default="scope">
                            {{
                    scope.row.authorType == '1' ? '教师' : scope.row.authorType == '2' ? '学生' : '校外'
                }}</template>
                    </el-table-column>
                    <el-table-column align="center" prop="authorName" label="完成人姓名">

                    </el-table-column>
                    <el-table-column align="center" prop="eduLevelId" label="学历">
                        <template #default="scope">
                            <Feedback :id="scope.row.eduLevelId" :list="xlList"></Feedback>
                        </template>
                    </el-table-column>
                    <el-table-column align="center" prop="authorUnit" label="工作单位">
                    </el-table-column>
                    <el-table-column align="center" prop="titleId" label="职称">
                        <template #default="scope">
                            <el-tree-select v-model="scope.row.titleId" node-key="id" :data="zcList"
                                :render-after-expand="false" disabled />
                        </template>
                    </el-table-column>
                    <el-table-column align="center" prop="workRatio" label="贡献率（%）">
                    </el-table-column>
                </el-table>
            </div>
        </div>
    </div>
</template>
<script setup>
import BaseHead from "@/views/project/components/BaseHead.vue";
import useCategoryStore from "@/store/modules/category";
const ruleForm = reactive({
});
const tableData = reactive([
]);

const categoryStore = useCategoryStore();
const { xlList, zcgsdwList, zcList, kjxkflList, skxkflList, hjjbList, hjdjList, hjnbList, xmlyList } = storeToRefs(categoryStore); // 解构状态
const { getxlList, getzcgsdwList, getzcList, getkjxkflList, getskxkflList, gethjjbList, gethjdjList, gethjnbList, getxmlyList } = categoryStore; // 解构方法

const getRuleForm = (i) => {
    if (!xlList.value.length) {
        getxlList()
    }
    if (!zcgsdwList.value.length) {
        getzcgsdwList()
    }
    if (!zcList.value.length) {
        getzcList()
    }
    if (!kjxkflList.value.length) {
        getkjxkflList()
    }
    if (!skxkflList.value.length) {
        getskxkflList()
    }
    if (!hjjbList.value.length) {
        gethjjbList()
    }
    if (!hjdjList.value.length) {
        gethjdjList()
    }
    if (!hjnbList.value.length) {
        gethjnbList()
    }
    if (!xmlyList.value.length) {
        getxmlyList()
    }

    if (i.honorAuthorVOs && i.honorAuthorVOs.length > 0) {
        tableData.length = 0; // 清空数组
        tableData.push(...i.honorAuthorVOs); // 添加新元素

    }
    for (const key in i) {
        ruleForm[key] = i[key];
    }
}
defineExpose({
    getRuleForm
})
</script>
<style lang="scss">
.gdlable {
    width: 140px;
}
</style>
<style scoped lang="scss">
@import url("@/views/achievement/index.scss");

:deep(.el-select--default) {


    .el-select__wrapper.is-disabled {
        background-color: #fff;
        box-shadow: 0 0 0 0px var(--el-select-disabled-border) inset;
        color: #606266;
        cursor: not-allowed;

        .el-select__selected-item {
            color: #606266;
        }
    }

    .el-select__suffix {
        display: none;
    }
}
</style>
